Cryptography

What is cryptography?

 

 

 Image is missing in html document.

 


 

 

Basic Terminology.

This concept leads us to the following definition.

Definition

    1. P is a finite set of possible plaintexts.
    2. C is a finite set of possible ciphertexts.
    3. K, the keyspace, is a finite set of possible keys.
    4. For each kÎ K, there is an encryption rule ekÎ E and a corresponding decryption rule dkÎ D. Each ek: P® C and dk: C® P are functions such that dk(ek(x)) = x for all plaintext xÎ P.

The main property is property 4. It says that if a plaintext x is encrypted using ek, and the resulting ciphertext is subsequently decrypted using dk, then the original plaintext x results. Clearly, ek is one-to-one, otherwise, decryption could not be accomplished in an unambiguous manner. For example, if y = ek(x1) = ek(x2) where x1 ¹ x2, then Bob has no way of knowing whether y should decrypt to x1 or x2.

Two Types of Cryptosystems

For today, we will be assuming that Alice and Bob have chosen a random key and exchanged secretly either in person or over a secure line. Now lets get to some simple cryptosystems. I will go through this first basic cryptosystem in excrutiating depth in order to really give a feel for what is going on.

Shift Cipher

ek(x) = (x + k) (modulo 26)

and

dk(y) = (y – k) (modulo 26)

for all x,yÎ Z26.

Is This a Cryptosystem?

    1. Let kÎ K and xÎ P, arbitrary.
    2. dk(ek(x)) = dk((x + k)(mod 26)) = ((x + k) – k) (mod 26) = x (mod 26) = x.

Here’s a simple example of the shift cipher in action. We will refer to the correspondences below for the example.

 

A

B

C

D

E

F

G

H

I

J

K

L

M

0

1

2

3

4

5

6

7

8

9

10

11

12

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

13

14

15

16

17

18

19

20

21

22

23

24

25

Example

marinersarethebest

12

0

17

8

13

4

17

18

0

17

4

19

7

4

1

4

18

19

23

11

2

19

24

15

2

3

11

2

15

4

18

15

12

15

3

4

XLCTYPCDLCPESPMPDE

I’m sure that all of us have seen puzzles like this in the newspaper or puzzle books and realize that this is not a difficult system to break. Just trying all the keys, although cumbersome, would not be difficult in the Shift Cipher, that is one of the reasons, in practice, it is not secure. The process of attempting to compute the key k, given a string of ciphertext, is called cryptanalysis. In general, we want cryptosystems in which an exhaustive key search is impossible(even for computers).

Now lets study a cryptosystem that has more algebra involved and a larger keyspace.

Affine Cipher

e(x) = (ax + b)(mod 26), where a,bÎ Z26, a ¹ 0.

ax + b º y (mod 26) to have a unique solution for x.

Nonexample: 2x º 0 (mod 26). This has two solution, x = 0 and x = 13, for the particular y = 0 and thus a = 2 will not work for a one-to-one affine function.

Trying out some elements of Z26, we start to discover that only some values of a have this property.

Claim: This congruence has a unique solution for every y if and only if gcd(a,26) = 1.

Proof

      1. (RAA) Assume gcd(a,26) ¹ 1.
      2. Note: a can be 0 because 0x º 0 (mod 26), has 26 solutions.

      3. Then gcd(a,26) = d > 1.
      4. Thus the congruence ax º 0 (mod 26) has at least two distinct solutions, namely x = 0 and x = 26/d, for the particular y = 0. x = 0 works obviously. Because d | a and d | 26, therefore, $ m,nÎ Z26 such that dm = a and dn = 26.
      5. So 26/d = n. And an = (dm)n = (dn)m = 26m º 0 (mod 26).

        This is a contradiction.

      6. Therefore, gcd(a,26) = 1.
          1. Assume x1, x2Î Z26, such that ax1 º ax2 (mod 26)
          2. Then a(x1 – x2) º 0 (mod 26)
          3. Thus, 26 | a(x1 – x2).
          4. By Lemma (*), or simply by division property, since 26 | a(x1 – x2), and gcd(a,26) = 1, we must therefore have that 26 | (x1 – x2).

i.e. x1 º x2 (mod 26) and the congruence has a unique solution.

For example, since gcd(4,26) = 2, it follows that ek(x) = 4x + 7 is not a valid encryption function: x and x + 13 will encrypt to the same value, for any xÎ Z26. Specifically,

ek(a) = ek(0) = 4(0) + 7 (mod 26) = 7, and ek(n) = ek(13) = 4(13) + 7 (mod 26) = 7.

Lemma(*): If a,b,cÎ Z26 such that gcd(a,b) = 1 and a | bc, then a | c.

Proof

(the gcd is a linear combination)

Note: There is nothing special about 26, this result can be generalized for any positive integer m > 1.

Thm. The congruence ax º b (mod m) has a unique solution xÎ Zm if and only if gcd(a,m) = 1.

So we have shown that the only one-to-one affine functions in Z26 are those of the form ax + b (mod m) where gcd(a,m) = 1 and bÎ Z26.

We have shown that the Affine Cipher satisfies the first 3 properties of the definition of a cryptosystem and that it satisfies the need for a one-to-one encryption rule, but we still need an associate decryption rule in order to decrypt the ciphertext.

The Decryption Rule

ax º y – b (mod 26).

We would like to say that x º a-1(y – b) (mod 26), but not all aÎ Z26 have an inverse.

(ask if you want to be shown, Lemma (*2))

Lemma(*2): Let a and n be integers, with n > 1. Then a has a multiplicative inverse modulo n if and only if gcd(a,n) = 1.

Proof

          1. Then there is a k such that ak º 1 (mod n).
          2. Thus, n is a divisor of ak – 1, so there must be some integer t so that
          3. ak – 1 º nt (mod n).

          4. Rewriting this as ak – nt º 1(mod n), we see that gcd(a,n) = 1.

ar + ns = 1.

            1. This means ar – 1 is divisible by n.
            2. So ar º 1 (mod n).
            3. This tells us r is the inverse of a.

Putting this all together, we finally obtain our Affine Cipher.

Affine Cipher Overview

K = {(a,b)Î Z26xZ26 : gcd(a,26) = 1}

For k = (a,b)Î K, define

ek(x) = (ax + b) (mod 26)

and dk(y) = a-1(y – b) (mod 26), for all x,yÎ Z26.

              1. Let k = (a,b)Î K and xÎ P, arbitrary.
              2. dk(ek(x)) = dk((ax + b)(mod 26)) = a-1((ax + b) – b) (mod 26)

= a-1(ax) (mod 26) = x (mod 26).

Example:

Note: We have developed the set {aÎ Zm : gcd(a,m) = 1}. We will denote this set as Zm*. We have introduced that Zm* has inverses, identities, associativity, and commutativity. It turns out that Zm* is in fact an abelian group called the prime residue group.

Proof of closure:

Let x, yÎ Zm*. Then gcd(x,m) = 1 and gcd(y,m) = 1. Then for some r,s,t,uÎ Z,

xr + ms º 1 (mod m) and yt + mu º 1 (mod m). Multiplying together yields,

(xr + ms)(yt + mu) º 1 (mod m)

xy(rt) + xrmu + ytms + mmsu º 1 (mod m),

or xy(rt) + m(xru + yts + msu) = 1 (mod m), rtÎ Z, and xru + yts + msuÎ Z.

Therefore, gcd(xy,m) = 1. Closure.

Do We Have a Larger Keyspace?

Note: In both the Shift Cipher and the Affine Cipher, once a key is chosen, each alphabetic character is mapped to a unique alphabetic character. For this reason, these cryptosystems are called monoalphabetic. These type of systems are easy to break by simply looking for the most common letters in the ciphertext and trying out the most common English letters in their place until an intelligible message is formed.

The following cryptosystem corrects these faults by offering a polyalphabetic approach to encryption.

 

 

 

 

 

Vigenere Cipher

For a key k = (k1, k2,…, km), we define

ek(x1, x2, …, xm) = (x1 + k1, x2 + k2, …, xm + km)

and dk(y1, y2, …, ym) = (y1 – k1, y2 – k2, …, ym – km), all operations in Z26.

Example:

thissystemsecure

19

7

8

18

18

24

18

19

4

12

18

4

2

20

17

4

4

13

2

17

24

15

19

4

13

2

17

24

15

19

4

13


23

20

10

9

16

13

11

23

17

14

9

2

17

13

21

17

Larger Keyspace

Let’s build another polyalphabetic cryptosystem this time using some linear algebra.

The Hill Cipher

and m linear combinations: k11x1 + k12x2 + … + k1mxm

k21x1 + k22x2 + … + k2mxm

km1x1 + km2x2 + … + kmmxm

Then we can get (y1, y2, …, ym) by:

, where kijÎ Z26.

Decryption of the Hill Cipher

Claim: A matrix K has an inverse modulo 26 if and only if gcd(det K, 26) = 1.

Proof

                1. Then the det K has an inverse in Z26. (We proved this earlier)
                2. Now, for 1 £ i £ m, 1 £ j £ m, define Kij to be the matrix obtained from K by deleting the ith row and the jth column.
                3. Define a matrix K* to have as its (i,j)-entry the value (-1)i+jdet Kji.
                4. Then it can be shown that K-1 = (det K)-1K*. (skipping over stuff here)
                5. Hence, K has an inverse.
                1. 1 = det I = det (KK-1) = det K det K-1
                2. Thus, det K is invertible in Z26.
                3. Therefore, gcd(det K, 26) = 1.

Hill Cipher Overview

For a key A, we define

eA(x) = Ax (mod 26)

and dA(y) = A-1y (mod 26), for all x,yÎ Z26.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Example: